<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>do-while</title>
    <script>
        function fundo(){
            var i = 1
            do {
                console.log(i)
                i++
            }while (i<=20)
        }
        function funAdd100(){
            var i = 1
            var sum = 0
            do{
                sum += i
                i++
            }while (i<=100)
            console.log(sum)
        }
        function funEven(){
            var i = 0
            var sum = 0
            do{
                if (i%2==0){
                    sum += i
                }
                i++
            }while (i<=100)
            console.log(sum)
        }

        function funBreak(){
            var i = 1
            do{
                if(i==3){
                    break
                }
                console.log(i)
                i++
            }while(i<=7)
            console.log('循环结束了')
        }
        function funContinue(){
            var i = 1
            do{
                if(i==3){
                    i++
                    continue
                }
                console.log(i)
                i++
            }while(i<=7)
            console.log('循环结束了')
        }
        function funX(){
            var i = 1
            do{
                console.log("1x"+ i +"=" + i)
                i++
            }while(i<=9)
        }
        function funXX(){
            var i = 1
            do{
                var line = ''
                var j = 1
                do{
                    line += j +"x"+ i +"=" + i*j + "  "
                    j++
                }while(j<=i)
                console.log(line)
                i++
            }while(i<=9)
        }
    </script>
</head>
<body>
    <button onclick="fundo()">循环20</button>
    <button onclick="funAdd100()">1-100之和</button>
    <button onclick="funEven()">1-100偶数和</button>
    <button onclick="funContinue()">跳过3</button>
    <button onclick="funBreak()">结束3</button>
    <button onclick="funX()">X</button>
    <button onclick="funXX()">乘法口诀</button>
</body>
</html>